﻿using System;
using System.Collections.Generic;
using TaleWorlds.CampaignSystem.Actions;
using TaleWorlds.CampaignSystem.Extensions;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

namespace TaleWorlds.CampaignSystem.LogEntries
{
	// Token: 0x020002F0 RID: 752
	public class SiegeAftermathLogEntry : LogEntry
	{
		// Token: 0x06002BD4 RID: 11220 RVA: 0x000B8ED3 File Offset: 0x000B70D3
		internal static void AutoGeneratedStaticCollectObjectsSiegeAftermathLogEntry(object o, List<object> collectedObjects)
		{
			((SiegeAftermathLogEntry)o).AutoGeneratedInstanceCollectObjects(collectedObjects);
		}

		// Token: 0x06002BD5 RID: 11221 RVA: 0x000B8EE1 File Offset: 0x000B70E1
		protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
		{
			base.AutoGeneratedInstanceCollectObjects(collectedObjects);
			collectedObjects.Add(this._capturedSettlement);
			collectedObjects.Add(this._decisionMaker);
		}

		// Token: 0x06002BD6 RID: 11222 RVA: 0x000B8F02 File Offset: 0x000B7102
		internal static object AutoGeneratedGetMemberValue_siegeAftermath(object o)
		{
			return ((SiegeAftermathLogEntry)o)._siegeAftermath;
		}

		// Token: 0x06002BD7 RID: 11223 RVA: 0x000B8F14 File Offset: 0x000B7114
		internal static object AutoGeneratedGetMemberValue_capturedSettlement(object o)
		{
			return ((SiegeAftermathLogEntry)o)._capturedSettlement;
		}

		// Token: 0x06002BD8 RID: 11224 RVA: 0x000B8F21 File Offset: 0x000B7121
		internal static object AutoGeneratedGetMemberValue_decisionMaker(object o)
		{
			return ((SiegeAftermathLogEntry)o)._decisionMaker;
		}

		// Token: 0x06002BD9 RID: 11225 RVA: 0x000B8F2E File Offset: 0x000B712E
		internal static object AutoGeneratedGetMemberValue_playerWasInvolved(object o)
		{
			return ((SiegeAftermathLogEntry)o)._playerWasInvolved;
		}

		// Token: 0x06002BDA RID: 11226 RVA: 0x000B8F40 File Offset: 0x000B7140
		public SiegeAftermathLogEntry(MobileParty leaderParty, IEnumerable<MobileParty> attackers, Settlement settlement, SiegeAftermathAction.SiegeAftermath siegeAftermath)
		{
			this._siegeAftermath = siegeAftermath;
			this._decisionMaker = leaderParty.LeaderHero;
			this._capturedSettlement = settlement;
			this._playerWasInvolved = false;
			using (IEnumerator<MobileParty> enumerator = attackers.GetEnumerator())
			{
				while (enumerator.MoveNext())
				{
					if (enumerator.Current == MobileParty.MainParty)
					{
						this._playerWasInvolved = true;
						break;
					}
				}
			}
		}

		// Token: 0x06002BDB RID: 11227 RVA: 0x000B8FB8 File Offset: 0x000B71B8
		public override ImportanceEnum GetImportanceForClan(Clan clan)
		{
			return ImportanceEnum.Zero;
		}

		// Token: 0x06002BDC RID: 11228 RVA: 0x000B8FBC File Offset: 0x000B71BC
		public override void GetConversationScoreAndComment(Hero talkTroop, bool findString, out string comment, out ImportanceEnum score)
		{
			score = ImportanceEnum.Zero;
			comment = "";
			if (this._playerWasInvolved && Hero.MainHero.CurrentSettlement == this._capturedSettlement && Hero.OneToOneConversationHero.IsNotable)
			{
				score = ImportanceEnum.VeryImportant;
				if (this._siegeAftermath == SiegeAftermathAction.SiegeAftermath.ShowMercy)
				{
					comment = "str_comment_endplayerbattle_you_stormed_this_city_showed_mercy";
				}
				if (this._siegeAftermath == SiegeAftermathAction.SiegeAftermath.Devastate)
				{
					comment = "str_comment_endplayerbattle_you_stormed_this_city_devastated";
				}
				if (this._siegeAftermath == SiegeAftermathAction.SiegeAftermath.Pillage)
				{
					comment = "str_comment_endplayerbattle_you_stormed_this_city";
				}
			}
		}

		// Token: 0x06002BDD RID: 11229 RVA: 0x000B902D File Offset: 0x000B722D
		public override string ToString()
		{
			return this.GetNotificationText().ToString();
		}

		// Token: 0x06002BDE RID: 11230 RVA: 0x000B903C File Offset: 0x000B723C
		public TextObject GetNotificationText()
		{
			TextObject textObject = null;
			if (this._siegeAftermath == SiegeAftermathAction.SiegeAftermath.ShowMercy)
			{
				textObject = new TextObject("{=wTh00qoj}{HERO.NAME} has showed mercy to {SETTLEMENT}.", null);
			}
			if (this._siegeAftermath == SiegeAftermathAction.SiegeAftermath.Devastate)
			{
				textObject = new TextObject("{=NeTp63aU}{HERO.NAME} has devastated {SETTLEMENT}.", null);
			}
			if (this._siegeAftermath == SiegeAftermathAction.SiegeAftermath.Pillage)
			{
				textObject = new TextObject("{=VzAqZucZ}{HERO.NAME} has pillaged {SETTLEMENT}.", null);
			}
			if (this._decisionMaker != null)
			{
				textObject.SetCharacterProperties("HERO", this._decisionMaker.CharacterObject, false);
			}
			textObject.SetTextVariable("SETTLEMENT", this._capturedSettlement.Name);
			return textObject;
		}

		// Token: 0x04000D23 RID: 3363
		[SaveableField(10)]
		private readonly SiegeAftermathAction.SiegeAftermath _siegeAftermath;

		// Token: 0x04000D24 RID: 3364
		[SaveableField(20)]
		private readonly Settlement _capturedSettlement;

		// Token: 0x04000D25 RID: 3365
		[SaveableField(30)]
		private readonly Hero _decisionMaker;

		// Token: 0x04000D26 RID: 3366
		[SaveableField(40)]
		private readonly bool _playerWasInvolved;
	}
}
